﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class DateToggleItem : ListToggleItem
{
    public Image bgImg;
    public Text text2;

    public Color bgActiveColor = Color.white;
    public Color bgDisactiveColor = Color.white;
    public Color textActiveColor = Color.white;
    public Color textDisactiveColor = Color.white;
    public Color text2ActiveColor = Color.white;
    public Color text2DisactiveColor = Color.white;

    bool m_Inited;

    public override void Awake()
    {
        base.Awake();

        if(!m_Inited)
            InitUI(false);
    }

    protected override void _OnToggleValueChange(bool isOn)
    {
        base._OnToggleValueChange(isOn);

        InitUI(isOn);
    }

    void InitUI(bool isOn)
    {
        m_Inited = true;

        //if(isOn)
        //    GameDebug.LogError($"{name} InitUI:{isOn}");

        if (bgImg)
            this.bgImg.color = isOn ? bgActiveColor : bgDisactiveColor;

        this.titleText.color = isOn ? textActiveColor : textDisactiveColor;

        this.text2.color = isOn ? text2ActiveColor : text2DisactiveColor;
    }
}
